<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
        .root {
            background-color: orange;
        }

        .second {
            background-color: lightgreen;
        }

        .third {
            background-color: lightblue;
        }
    </style>
</head>

<body>
    <div id="app" class="root">
        <div>{{root}}</div>
        <second-com></second-com>
        <second-com></second-com>
    </div>
    <script src="http://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

    <script type="text/javascript">
        /*
      Vue调试工具安装与基本使用
    */
        Vue.component('second-com', {
            data: function () {
                return {
                    second: '二级组件'
                }
            },
            template: `<div class='second'>
        <div>{{second}}</div>
        <third-com></third-com>
        <third-com></third-com>
        <third-com></third-com>
      </div>`
        });
        Vue.component('third-com', {
            data: function () {
                return {
                    third: '三级组件'
                }
            },
            template: '<div class="third"><div>{{third}}</div></div>'
        });

        var vm = new Vue({
            el: '#app',
            data: {
                root: '顶层组件'
            }
        });
    </script>
</body>

</html>